package cn.edu.szu.bigdata.secure;


import cn.edu.szu.bigdata.util.IPUtil;
import com.google.gson.Gson;
import com.qihoo.wzws.rzb.routine.po.CommonStatBean;
import com.qihoo.wzws.rzb.routine.po.StatBean;
import com.qihoo.wzws.rzb.routine.po.StatBeanComparator;
import com.qihoo.wzws.rzb.secure.po.AttackEntity;
import com.qihoo.wzws.rzb.secure.po.AttackEntityComparator;
import com.qihoo.wzws.rzb.secure.po.AttackEvent;
import com.qihoo.wzws.rzb.secure.po.AttackStatBean;
import com.qihoo.wzws.rzb.secure.po.AttackTypeObject;
import com.qihoo.wzws.rzb.secure.po.CCEntity;
import com.qihoo.wzws.rzb.secure.po.CCEntityComparator;
import com.qihoo.wzws.rzb.secure.po.CommBean;
import com.qihoo.wzws.rzb.secure.po.CommBeanComparator;
import com.qihoo.wzws.rzb.secure.po.OverViewEntity;
import com.qihoo.wzws.rzb.util.DateUtil;
import com.qihoo.wzws.rzb.util.SecurityConstants;
import com.qihoo.wzws.rzb.util.ip.IPRegion;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

public class AttackReportCache {
    public static Map<String, Long> overviewMap = new HashMap();
    public static AtomicLong records = new AtomicLong(0L);
    public static Date startTime;
    public static AttackEntity firstAttack;
    public static Date endTime;
    public static List<AttackEntity> attackList = new ArrayList();
    public static AtomicLong attackCount = new AtomicLong(0L);
    public static AtomicLong ccCount = new AtomicLong(0L);
    public static AtomicLong longUrlCount = new AtomicLong(0L);
    public static List<Date> dataFrom = new ArrayList();
    public static Map<String, Long> dayAttackMap = new HashMap();
    public static Map<String, Long> hourAttackMap = new HashMap();
    public static Map<String, Integer> dayCCAttackMap = new HashMap();
    public static Map<String, Integer> hourCCAttackMap = new HashMap();
    public static List<CommBean> attackIPList = new ArrayList();
    public static List<CommBean> ccIPList = new ArrayList();
    public static Map<String, Integer> ccIPMap = new HashMap();
    public static List<AttackTypeObject> allAttackTypelist = new ArrayList();
    private static Map<String, AttackEntity> attackMaps = new ConcurrentHashMap();
    public static List<CCEntity> ccList = new ArrayList();
    public static CCEntity firstCC = new CCEntity();

    public AttackReportCache() {
    }

    public static void initData() {
        Set<String> set = dayAttackMap.keySet();
        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");

        try {
            Iterator iter1 = set.iterator();

            while(iter1.hasNext()) {
                String date = (String)iter1.next();
                Date myDate1 = dateFormat1.parse(date);
                dataFrom.add(myDate1);
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }

        Collections.sort(dataFrom);
        Map<String, Long> attackip = new HashMap();
        Iterator iter2 = attackList.iterator();

        while(iter2.hasNext()) {
            AttackEntity entity = (AttackEntity)iter2.next();
            if (!attackip.containsKey(entity.getIp())) {
                attackip.put(entity.getIp(), 1L);
            } else {
                attackip.put(entity.getIp(), attackip.get(entity.getIp()) + 1L);
            }
        }

        iter2 = attackip.entrySet().iterator();

        CommBean c;
        Map.Entry entry;
        while(iter2.hasNext()) {
            entry = (Map.Entry)iter2.next();
            c = new CommBean((String)entry.getKey(), ((Long)entry.getValue()).intValue());
            attackIPList.add(c);
        }

        iter2 = ccList.iterator();

        while(iter2.hasNext()) {
            CCEntity entity = (CCEntity)iter2.next();
            if (!ccIPMap.containsKey(entity.getIp())) {
                ccIPMap.put(entity.getIp(), 1);
            } else {
                ccIPMap.put(entity.getIp(), ccIPMap.get(entity.getIp()) + 1);
            }
        }

        iter2 = ccIPMap.entrySet().iterator();

        while(iter2.hasNext()) {
            entry = (Map.Entry)iter2.next();
            c = new CommBean((String)entry.getKey(), (Integer)entry.getValue());
            ccIPList.add(c);
        }

        Map<String, List<AttackEntity>> allAttackMap = new HashMap();
        iter2 = attackList.iterator();

        while(iter2.hasNext()) {
            AttackEntity i = (AttackEntity)iter2.next();
            if (allAttackMap.containsKey(i.getRule())) {
                (allAttackMap.get(i.getRule())).add(i);
            } else {
                List<AttackEntity> tmp = new ArrayList();
                tmp.add(i);
                allAttackMap.put(i.getRule(), tmp);
            }
        }

        iter2 = allAttackMap.entrySet().iterator();

        Map.Entry<String, List<AttackEntity>> entry1;
        while(iter2.hasNext()) {
            entry1= (Map.Entry)iter2.next();
            AttackTypeObject temp = new AttackTypeObject();
            temp.setTypeName(entry1.getKey());
            temp.setTypeList(entry1.getValue());
            temp.setTypeId(SecurityConstants.attackTypeNameIdMap.get(entry1.getKey()));
            allAttackTypelist.add(temp);
        }
    }

    public static AttackEvent getAttackEvt(NumberFormat intformat) {
        AttackEvent attackEvent = new AttackEvent();
        if (attackList.size() > 0) {
            attackEvent.setFirstAttackType(firstAttack.getRule());
            attackEvent.setFirstIp(firstAttack.getIp());
            attackEvent.setFirstCount(firstAttack.getCount());
            attackEvent.setFirstStartTimeStr(firstAttack.getStarttime());
            attackEvent.setFirstStartTime(DateUtil.parseDateTime(firstAttack.getStarttime()));
            attackEvent.setFirstCountStr(intformat.format(attackEvent.getFirstCount()));
            attackEvent.setSumAtt(intformat.format(attackCount));
            attackEvent.setSumIP(intformat.format(attackIPList.size()));
            attackEvent.setFirstRegion(IPUtil.getRegion(attackEvent.getFirstIp()));
            String Maxtime = null;
            int Maxcouns = 0;
            Iterator i$ = hourAttackMap.entrySet().iterator();

            while(true) {
                Map.Entry entry;
                do {
                    if (!i$.hasNext()) {
                        attackEvent.setHotDayHour(Maxtime);
                        attackEvent.setHotDayhourCount(Maxcouns);
                        attackEvent.setHotDayhourCountStr(intformat.format((long)Maxcouns));
                        Collections.sort(attackIPList, new CommBeanComparator());
                        attackEvent.setHotIP((attackIPList.get(0)).getName());
                        attackEvent.setHostRegion(IPUtil.getRegion((attackIPList.get(0)).getName()));
                        return attackEvent;
                    }

                    entry = (Map.Entry)i$.next();
                } while(Maxtime != null && Maxcouns >= ((Long)entry.getValue()).intValue());

                Maxtime = (String)entry.getKey();
                Maxcouns = ((Long)entry.getValue()).intValue();
            }
        } else {
            return attackEvent;
        }
    }

    public static AttackEvent getCcEvt(NumberFormat intformat) {
        AttackEvent CcEvent = new AttackEvent();
        if (AnalyzeSingle.useCC && ccList.size() > 0) {
            CcEvent.setHotDayHour((ccList.get(0)).getStarttime());
            CcEvent.setHotDayhourCount((ccList.get(0)).getCount());
            CcEvent.setHotDayhourCountStr(intformat.format(CcEvent.getHotDayhourCount()));
            Collections.sort(ccIPList, new CommBeanComparator());
            CcEvent.setHotIP((ccIPList.get(0)).getName());
            CcEvent.setHostRegion(IPUtil.getRegion((ccIPList.get(0)).getName()));
            String Maxtime = null;
            int Maxcouns = 0;
            Iterator i$ = hourCCAttackMap.entrySet().iterator();

            while(true) {
                Map.Entry entry;
                do {
                    if (!i$.hasNext()) {
                        CcEvent.setHotDayHour(Maxtime);
                        CcEvent.setHotDayhourCount(Maxcouns);
                        CcEvent.setHotDayhourCountStr(intformat.format(Maxcouns));
                        CcEvent.setSumAtt(intformat.format(ccCount));
                        CcEvent.setSumIP(intformat.format(ccIPList.size()));
                        CcEvent.setFirstIp(firstCC.getIp());
                        CcEvent.setFirstUri(firstCC.getUrl());
                        CcEvent.setFirstCount(firstCC.getCount());
                        CcEvent.setFirstStartTimeStr(firstCC.getStarttime());
                        CcEvent.setFirstCountStr(intformat.format(CcEvent.getFirstCount()));
                        CcEvent.setFirstRegion(IPUtil.getRegion(CcEvent.getFirstIp()));
                        return CcEvent;
                    }

                    entry = (Map.Entry)i$.next();
                } while(Maxtime != null && Maxcouns >= (Integer)entry.getValue());

                Maxtime = (String)entry.getKey();
                Maxcouns = (Integer)entry.getValue();
            }
        } else {
            return CcEvent;
        }
    }

    public static void put2OverViewMap(String key) {
        if (overviewMap.containsKey(key)) {
            overviewMap.put(key, overviewMap.get(key) + 1L);
        } else {
            overviewMap.put(key, 1L);
        }

    }

    public static void put2dayAttackMap(String key) {
        if (dayAttackMap.containsKey(key)) {
            dayAttackMap.put(key, dayAttackMap.get(key) + 1L);
        } else {
            dayAttackMap.put(key, 1L);
        }

    }

    public static void put2dayCCAttackMap(String key, Integer value) {
        if (dayCCAttackMap.containsKey(key)) {
            dayCCAttackMap.put(key, dayCCAttackMap.get(key) + value);
        } else {
            dayCCAttackMap.put(key, value);
        }

    }

    public static void put2hourCCAttackMap(String key, Integer value) {
        if (hourCCAttackMap.containsKey(key)) {
            hourCCAttackMap.put(key, hourCCAttackMap.get(key) + value);
        } else {
            hourCCAttackMap.put(key, value);
        }

    }

    public static void put2hourAttackMap(String key) {
        if (hourAttackMap.containsKey(key)) {
            hourAttackMap.put(key, hourAttackMap.get(key) + 1L);
        } else {
            hourAttackMap.put(key, 1L);
        }

    }

    public static String outputOverViewForMail() {
        List<OverViewEntity> list = new ArrayList();
        Iterator i$ = overviewMap.entrySet().iterator();

        while(i$.hasNext()) {
            Map.Entry<String, Long> entry = (Map.Entry)i$.next();
            list.add(new OverViewEntity(entry.getKey(), entry.getValue()));
        }

        if (longUrlCount.get() > 0L) {
            list.add(new OverViewEntity("超长URL", longUrlCount.get()));
        }

        if (ccCount.get() > 0L) {
            list.add(new OverViewEntity("CC攻击", ccCount.get()));
        }

        Collections.sort(list);
        StringBuilder sb = new StringBuilder();

        for(int i = 0; i < list.size(); ++i) {
            OverViewEntity entity = list.get(i);
            sb.append(entity.getName() + ":" + entity.getCount());
            if (i != list.size() - 1) {
                sb.append("|");
            }
        }

        return sb.toString();
    }

    public static List<OverViewEntity> outputOverViewListForMail() {
        List<OverViewEntity> list = new ArrayList();
        Iterator i$ = overviewMap.entrySet().iterator();

        while(i$.hasNext()) {
            Map.Entry<String, Long> entry = (Map.Entry)i$.next();
            list.add(new OverViewEntity(entry.getKey(), entry.getValue()));
        }

        if (longUrlCount.get() > 0L) {
            list.add(new OverViewEntity("超长URL", longUrlCount.get()));
        }

        if (ccCount.get() > 0L) {
            list.add(new OverViewEntity("CC攻击", ccCount.get()));
        }

        Collections.sort(list);
        return list;
    }

    public static void put2AttMap(String key, AttackEntity entity) {
        if (attackMaps.containsKey(key)) {
            AttackEntity att = attackMaps.get(key);
            att.setCount(att.getCount() + 1);
        } else {
            attackMaps.put(key, entity);
        }

    }

    public static void put2CCList(CCEntity entity) {
        ccList.add(entity);
    }

    public static int getattackTypeSum() {
        int attack = overviewMap.size();
        return attack;
    }

    public static String ForallDaysDetailsjson() {
        Map<String, Object> allDaysDetailsObject = new HashMap();
        int days = dataFrom.size();
        String day = null;
        List<AttackStatBean> attackDayHourList = new ArrayList();
        int j;
        int attackC;
        int ccC;
        String dayHourStr;
        AttackStatBean asb;
        String[] allDaysDetailsKeys;
        String[] allDaysDetailsAttackVals;
        if (days > 2) {
            List<AttackStatBean> attackDayList = new ArrayList();

            for(j = 0; j < dataFrom.size(); ++j) {
                Date date = dataFrom.get(j);
                attackC = 0;
                ccC = 0;
                dayHourStr = DateUtil.formatDate(date);
                if (dayAttackMap.containsKey(dayHourStr)) {
                    attackC = (dayAttackMap.get(dayHourStr)).intValue();
                }

                if (dayCCAttackMap.containsKey(dayHourStr)) {
                    ccC = dayCCAttackMap.get(dayHourStr);
                }

                asb = new AttackStatBean(dayHourStr, attackC, ccC);
                attackDayList.add(asb);
            }

            allDaysDetailsKeys = new String[attackDayList.size()];
            allDaysDetailsAttackVals = new String[attackDayList.size()];
            String[] allDaysDetailsCCVals = new String[attackDayList.size()];

            for(ccC = 0; ccC < attackDayList.size(); ++ccC) {
                AttackStatBean bean = attackDayList.get(ccC);
                allDaysDetailsKeys[ccC] = bean.getDate();
                allDaysDetailsAttackVals[ccC] = String.valueOf(bean.getAttackCount());
                allDaysDetailsCCVals[ccC] = String.valueOf(bean.getCcCount());
            }

            attackDayList.clear();
            allDaysDetailsObject.put("attackDeatilKey", allDaysDetailsKeys);
            allDaysDetailsObject.put("attackAttackDeatilVal", allDaysDetailsAttackVals);
            allDaysDetailsObject.put("attackCCDeatilVal", allDaysDetailsCCVals);
        } else {
            for(int i = 0; i < dataFrom.size(); ++i) {
                day = DateUtil.formatDate((Date)dataFrom.get(i));

                for(j = 0; j < 24; ++j) {
                    String hourStr = "";
                    if (j < 10) {
                        hourStr = "0" + String.valueOf(j);
                    } else {
                        hourStr = String.valueOf(j);
                    }

                    attackC = 0;
                    ccC = 0;
                    dayHourStr = day + " " + hourStr;
                    if (hourAttackMap.containsKey(dayHourStr)) {
                        attackC = (hourAttackMap.get(dayHourStr)).intValue();
                    }

                    if (hourCCAttackMap.containsKey(dayHourStr)) {
                        ccC = hourCCAttackMap.get(dayHourStr);
                    }

                    asb = new AttackStatBean(dayHourStr, attackC, ccC);
                    attackDayHourList.add(asb);
                }
            }

            allDaysDetailsKeys = new String[attackDayHourList.size()];
            allDaysDetailsAttackVals = new String[attackDayHourList.size()];

            for(attackC = 0; attackC < attackDayHourList.size(); ++attackC) {
                AttackStatBean bean = attackDayHourList.get(attackC);
                allDaysDetailsKeys[attackC] = bean.getDate();
                allDaysDetailsKeys[attackC] = String.valueOf(bean.getAttackCount());
                allDaysDetailsAttackVals[attackC] = String.valueOf(bean.getCcCount());
            }

            attackDayHourList.clear();
            allDaysDetailsObject.put("attackDeatilKey", allDaysDetailsKeys);
            allDaysDetailsObject.put("attackAttackDeatilVal", allDaysDetailsKeys);
            allDaysDetailsObject.put("attackCCDeatilVal", allDaysDetailsAttackVals);
        }

        Gson gson = new Gson();
        String allDaysDetailsjson = gson.toJson(allDaysDetailsObject);
        return allDaysDetailsjson;
    }

    public static String ForattackVObjectjson() {
        List<CommonStatBean> typeList = new ArrayList();
        Iterator i$ = overviewMap.keySet().iterator();

        CommonStatBean c;
        while(i$.hasNext()) {
            String key = (String)i$.next();
            c = new CommonStatBean();
            c.setKey(key);
            c.setCount(((Long)overviewMap.get(key)).intValue());
            typeList.add(c);
        }

        Map<String, Integer> secDimCountMap = new HashMap();
        secDimCountMap.put("数据", 0);
        secDimCountMap.put("服务器", 0);
        secDimCountMap.put("应用", 0);
        secDimCountMap.put("文件", 0);
        secDimCountMap.put("其他", 0);
        if (typeList != null && typeList.size() > 0) {
            for(int i = 0; i < typeList.size(); ++i) {
                c = typeList.get(i);
                String key = SecurityConstants.secDimMap.get(c.getKey());
                if (secDimCountMap.containsKey(key)) {
                    int count = secDimCountMap.get(key) + c.getCount();
                    secDimCountMap.put(key, count);
                } else {
                    secDimCountMap.put(key, c.getCount());
                }
            }
        }

        int max = 0;
        int sum = 0;
        i$ = secDimCountMap.entrySet().iterator();

        while(i$.hasNext()) {
            Map.Entry<String, Integer> entry = (Map.Entry)i$.next();
            if (entry.getValue() > max) {
                sum += entry.getValue();
            }
        }

        double avg = (sum / secDimCountMap.size());
        Map<String, Object> attackVObject = new HashMap();
        List<Integer> attackVList = new ArrayList();
        List<Map> listMap = new ArrayList();
        i$ = secDimCountMap.entrySet().iterator();

        while(i$.hasNext()) {
            Map.Entry<String, Integer> entry = (Map.Entry)i$.next();
            double val = (double)entry.getValue() / avg;
            if (val >= 1.0) {
                val = 1.0;
            } else if (val < 0.08) {
                val *= 10.0;
            }

            attackVList.add((int)(val * 100.0));
            HashMap<String, Object> typeListMap = new HashMap();
            typeListMap.put("text", entry.getKey());
            typeListMap.put("max", 100);
            listMap.add(typeListMap);
        }

        Object[] attackArrays = attackVList.toArray();
        attackVObject.put("attackVKeyList", listMap);
        attackVObject.put("attackVValList", attackArrays);
        Gson gson = new Gson();
        return gson.toJson(attackVObject);
    }

    public static String ForAttackDatajson() {
        Map<String, Object> attackTypeObject = new HashMap();
        if (overviewMap != null && overviewMap.size() > 0) {
            String[] typeKeyList = new String[overviewMap.size()];
            List<Map> listMap = new ArrayList();
            int i = 0;

            for(Iterator i$ = overviewMap.entrySet().iterator(); i$.hasNext(); ++i) {
                Map.Entry<String, Long> entry = (Map.Entry)i$.next();
                typeKeyList[i] = entry.getKey();
                HashMap<String, Object> typeListMap = new HashMap();
                typeListMap.put("name", entry.getKey());
                typeListMap.put("value", entry.getValue());
                listMap.add(typeListMap);
            }

            attackTypeObject.put("typeKeyList", typeKeyList);
            attackTypeObject.put("typeList", listMap);
        }

        Gson gson = new Gson();
        return gson.toJson(attackTypeObject);
    }

    public static void sortAttlist() {
        Iterator i$ = attackMaps.entrySet().iterator();

        while(i$.hasNext()) {
            Map.Entry<String, AttackEntity> entry = (Map.Entry)i$.next();
            attackList.add(entry.getValue());
        }

        Collections.sort(attackList, new AttackEntityComparator());
    }

    public static void sortCClist() {
        Collections.sort(ccList, new CCEntityComparator());
    }

    public static List<StatBean> GetCcIPRegionList(NumberFormat intformat, NumberFormat performat) {
        Long ccCount = new Long(ccList.size());
        List<StatBean> ccIPRegionList = new ArrayList();

        for(int i = 0; i < ccIPList.size(); ++i) {
            CommBean cb = ccIPList.get(i);
            IPRegion region = IPUtil.getIPRegionLocal(cb.getName());
            if (region != null) {
                String ipRegion = region.getCountry();
                if (region.getCountry().indexOf("中国") > -1) {
                    if (region.getCity() != null && !region.getProvince().equals(region.getCity())) {
                        ipRegion = ipRegion + "-" + region.getProvince() + region.getCity();
                    } else {
                        ipRegion = ipRegion + "-" + region.getProvince();
                    }
                }

                StatBean sb = new StatBean();
                sb.setIp(cb.getName());
                sb.setCountry(ipRegion);
                sb.setVisit(cb.getCount());
                sb.setVisitStr(intformat.format(cb.getCount()));
                sb.setVisitRate(performat.format((double)Long.valueOf((long)cb.getCount()) / (double)ccCount));
                ccIPRegionList.add(sb);
            }
        }

        return ccIPRegionList;
    }

    public static List<StatBean> GetAttackIPRegionList(NumberFormat intformat, NumberFormat performat) {
        Long attackCount = new Long( AttackReportCache.attackCount.intValue());
        List<StatBean> attackIPRegionList = new ArrayList();

        for(int i = 0; i < attackIPList.size(); ++i) {
            CommBean cb = attackIPList.get(i);
            IPRegion region = IPUtil.getIPRegionLocal(cb.getName());
            if (region != null) {
                String ipRegion = region.getCountry();
                if (region.getCountry().indexOf("中国") > -1) {
                    if (region.getCity() != null && !region.getProvince().equals(region.getCity())) {
                        ipRegion = ipRegion + "-" + region.getProvince() + region.getCity();
                    } else {
                        ipRegion = ipRegion + "-" + region.getProvince();
                    }
                }

                StatBean sb = new StatBean();
                sb.setIp(cb.getName());
                sb.setCountry(ipRegion);
                sb.setVisit(cb.getCount());
                sb.setVisitStr(intformat.format((long)cb.getCount()));
                sb.setVisitRate(performat.format((double)Long.valueOf((long)cb.getCount()) / (double)attackCount));
                attackIPRegionList.add(sb);
            }
        }

        Collections.sort(attackIPRegionList, new StatBeanComparator());
        return attackIPRegionList;
    }

    public static List<CommBean> GetAttackCountryRegionList(NumberFormat intformat) {
        Map<String, Integer> attackCountryMap = new HashMap();

        IPRegion region;
        int count;
        for(int i = 0; i < attackIPList.size(); ++i) {
            CommBean cb = (CommBean)attackIPList.get(i);
            region = IPUtil.getIPRegionLocal(cb.getName());
            if (region != null) {
                count = 0;
                if (ccIPMap.containsKey(cb.getName())) {
                    count = (Integer)ccIPMap.get(cb.getName());
                    ccIPMap.remove(cb.getName());
                }

                count = cb.getCount() + count;
                if (region.getCountry().indexOf("局域网") <= -1 && region.getCountry().indexOf("骨干网") <= -1) {
                    if (attackCountryMap.containsKey(region.getCountry())) {
                        attackCountryMap.put(region.getCountry(), (Integer)attackCountryMap.get(region.getCountry()) + count);
                    } else {
                        attackCountryMap.put(region.getCountry(), count);
                    }
                }
            }
        }

        Iterator i$ = ccIPMap.entrySet().iterator();

        while(i$.hasNext()) {
            Map.Entry<String, Integer> entry = (Map.Entry)i$.next();
            region = IPUtil.getIPRegionLocal(entry.getKey());
            if (region != null) {
                count = (Integer)entry.getValue();
                if (region.getCountry().indexOf("局域网") <= -1 && region.getCountry().indexOf("骨干网") <= -1) {
                    if (attackCountryMap.containsKey(region.getCountry())) {
                        attackCountryMap.put(region.getCountry(), (Integer)attackCountryMap.get(region.getCountry()) + count);
                    } else {
                        attackCountryMap.put(region.getCountry(), count);
                    }
                }
            }
        }

        List<CommBean> attackCountryRegionSortList = new ArrayList();
        i$ = attackCountryMap.entrySet().iterator();

        while(i$.hasNext()) {
            Map.Entry<String, Integer> entry = (Map.Entry)i$.next();
            attackCountryRegionSortList.add(new CommBean((String)entry.getKey(), (Integer)entry.getValue()));
        }

        attackCountryMap.clear();
        Collections.sort(attackCountryRegionSortList, new CommBeanComparator());
        List<CommBean> attackCountryRegionList = new ArrayList();
        i$ = attackCountryRegionSortList.iterator();

        while(i$.hasNext()) {
            CommBean bean = (CommBean)i$.next();
            attackCountryRegionList.add(new CommBean(bean.getName(), intformat.format((long)bean.getCount())));
        }

        attackCountryRegionSortList.clear();
        return attackCountryRegionList;
    }
}